/*
 * 文件名称: MyClient.java Copyright 2011-2016 Ximalaya All right reserved.
 */
package com.zxy.socketdemo;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.Socket;

/**
 * @author Bird Zhang
 */
public class MyClient {
  static Socket server;

  public static void main(String[] args) throws Exception {
    server = new Socket(InetAddress.getLocalHost(), 5678, InetAddress.getLocalHost(), 10086);
    BufferedReader in = new BufferedReader(new InputStreamReader(server.getInputStream()));
    PrintWriter out = new PrintWriter(server.getOutputStream());
    BufferedReader wt = new BufferedReader(new InputStreamReader(System.in));
    while (true) {
      String str = wt.readLine();
      out.println(str);
      out.flush();
      if (str.equals("end")) {
        break;
      }
      System.out.println(in.readLine());
    }
    server.close();
  }
}
